<!doctype html public "-//w3c//dtd html 4.0 transitional//en">


<!-- WARNING! This file is generated. -->
<!-- To alter documentation, edit files in src directory -->


<html><head>
<title>Configuring the File Reporter</title>
<link rel="stylesheet" href="utplsql.css" content="text/css">
<meta name="keywords" content="utPLSQL, PL\SQL, Unit Testing, Framework, Oracle"/>
<meta name="description" content="Unit Testing PL\SQL"/>
<meta name="title" content="Configuring the File Reporter"/>
<meta name="author" content="Steven Feuerstein, Chris Rimmer, Patrick Barel"/>
<meta name="copyright" content="(C) 2000-2005 Steven Feuerstein, Chris Rimmer, Patrick Barel"/>
</head><body>
<div class="purple_bar"><a href="index.html"><img src="utplsql.jpg" border=0></a></div>
<p>[ <A href="index.html">Home</A>
 | <A href="started.html">Getting Started</A>
 | <A href="buildpack.html">Build Test Packages</A>
 | <A href="examples.html">Examples</A>
 | <A href="userguide.html">User Guide</A>
 | <A href="release.html">Release Notes</A>
 | <A href="map.html">Document Map</A> ]</p>
<p><A href="reporter.html">&lt; Previous Section: Custom Reporter Packages</A> | <A href="release.html">Next Section: Release Notes &gt;</A></p>
<!-- Begin utPLSQL Body -->
<!-- $Id: fileout.html,v 1.2 2005/05/10 14:23:04 chrisrimmer Exp $ -->
<h1>
Configuring the File Reporter
</h1>

<h2>
<a name="outline"></a>Outline
</h2>
By default, the results of a test run are written to the screen 
(via the default Output Reporter).  The subprograms described in this section were created 
by Rainer Medert to allow these results to be written to file instead.
They form part of the utConfig package.
Don't forget that you will first need to enable file output from the database 
via the UTL_FILE_DIR parameter in order to do this.

<h2>
<a name="setgetfile"></a>Turning file output on
</h2>

<p>To turn on file output, you will need to switch to using the File Reporter, or a custom reporter
that uses it.  See <a href="reporter">this page</a> for details.</p>

<h2>
<a name="setfiledir"></a>Setting the directory to be used
</h2>

<p>Once file output has been turned on, you can specify which directory the 
files will be written to using the following procedure:</p>

<pre>PROCEDURE setfiledir (
  dir_in IN VARCHAR2 := NULL, 
  username_in IN VARCHAR2 := NULL
);</pre>

<p>the directory given will have to have been specified for output in a 
UTL_FILE_DIR database parameter, as mentioned above.</p> 

<p>To see which directory is being used for output, use the following:</p>

<pre>FUNCTION filedir (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;</pre>

<h2>
<a name="filename1"></a>Formatting the output filenames
</h2>

<p>The structure of the filenames used for output is as follows:</p>

<pre>&lt;user-prefix&gt;_[program-name_]&lt;date&gt;&lt;extension&gt;</pre>

<p>Each of these elements can be configured using the following procedures.</p>

<p>The user-prefix is an arbitrary string.  It defaults to the username of the currently connected user, but can be set (and returned) using the following:</p>

<pre>-- Set the file prefix for a user
PROCEDURE setuserprefix (
  userprefix_in IN VARCHAR2 := NULL, 
  username_in IN VARCHAR2 := NULL
);

-- Get the file prefix for a user
FUNCTION userprefix (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;</pre>

<a name="filename2"></a>
<p>The program-name is the name of the tested program, or the test suite 
being run.  By default, this is element is not used in the generated filename.
To turn this on or off (and to determine the current setting), use the
following:</p>

<pre>-- Set the include program name flag for a user
PROCEDURE setincludeprogname (
  incname_in IN BOOLEAN := FALSE, 
  username_in IN VARCHAR2 := NULL
);

-- Get the include program name flag for a user
FUNCTION includeprogname (username_in IN VARCHAR2 := NULL) RETURN BOOLEAN;</pre>

<a name="filename3"></a>
<p>The date element of the filename is simply SYSDATE converted to a string.  The default format is 'YYYYDDMMHH24MISS', but this can be set (and returned) using the following:</p>

<pre>-- Set the date format for a user
PROCEDURE setdateformat (
  dateformat_in IN VARCHAR2 := 'yyyyddmmhh24miss', 
  username_in IN VARCHAR2 := NULL
);
          
-- Get the date format for a user
FUNCTION dateformat (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;</pre>

<a name="filename4"></a>
<p>The final element of the filename that can be configured is the extension.
This defaults to ".UTF" but can be set (and returned) using the following:</p>

<pre>-- Set the file extension for a user
PROCEDURE setfileextension (
  fileextension_in IN VARCHAR2 := '.UTF', 
  username_in IN VARCHAR2 := NULL
);

-- Get the file extension for a user
FUNCTION fileextension (username_in IN VARCHAR2 := NULL) RETURN VARCHAR2;</pre>

<p><b>Note</b> The initial dot must be included, otherwise there will be none
in the resulting filename!</p>

<h2>
<a name="allinone"></a>Setting all the parameters at once
</h2>

<p>It is possible to set all the file output parameters at once using the following procedure:</p>

<pre>PROCEDURE setfileinfo ( 
  dir_in IN VARCHAR2 := NULL,
  userprefix_in IN VARCHAR2 := NULL, 
  incname_in IN BOOLEAN := FALSE,     
  dateformat_in IN VARCHAR2 := 'yyyyddmmhh24miss', 
  fileextension_in IN VARCHAR2 := '.UTF',
  username_in IN VARCHAR2 := NULL
);</pre>

<p>To get back all of the file output parameters simultaneously, use the following function:<p>

<pre>FUNCTION fileinfo (username_in IN VARCHAR2 := NULL) RETURN rec_fileinfo;</pre>

<p>The record type <code>rec_fileinfo</code> is defined in the utConfig package and has one field for each of the parameters.<p>

<p>

<!-- End utPLSQL Body -->
<p><A href="reporter.html">&lt; Previous Section: Custom Reporter Packages</A> | <A href="release.html">Next Section: Release Notes &gt;</A></p>
<div class="purple_bar"><a href="index.html"><img src="utplsql.jpg" border=0></a></div>
<p class="copyright">Copyright (C) 2000-2005 <A href="mailto:steven@stevenfeuerstein.com">Steven Feuerstein<A>, <A href="mailto:c@24.org.uk">Chris Rimmer<A>, <A href="mailto:pbarel@vda.nl">Patrick Barel<A> All rights reserved</p>
</body></html>